#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <map>

#include "main.h"
#include "log.h"

using namespace std;

int main() {
	/*try {*/
	cout << "S.Prashant Sabnekar's shortcut-teller1.0 Running\nThanks for using shortcut-teller\n";
	
	HWND ActiveWndHWND; // Holds the active window HWND
	HWND GuidedHWND = NULL; //
	char WinTitle[DEF_STR_SIZE];
	int GetWinTitleRes = -1;
	
	cFileLog log("log.txt");

	while (true) {
		ActiveWndHWND = GetForegroundWindow(); // Update ActiveWnd
			
		GetWinTitleRes = GetWindowText(ActiveWndHWND,WinTitle,DEF_STR_SIZE);

		if (GuidedHWND != ActiveWndHWND) {
			if (0 == GetWinTitleRes) {
				log.printStatus(LOG_INVALID_HWND,ActiveWndHWND);
			} else {
				log.printStatus(LOG_NEW,WinTitle,ActiveWndHWND);
			}

			if (0 == strcmp("My Computer",WinTitle)) {
				MessageBox(NULL,"You can open My Computer by using shortcut: 'WindowsLogo + e'","Shortcut Teller",MB_OK);
			} else if (0 == strcmp("System Properties",WinTitle)) {
				MessageBox(NULL,"You can open System Properties Dialog by using shortcut: 'WindowsLogo + PauseBreak'","Shortcut Teller",MB_OK);
			}

			GuidedHWND = ActiveWndHWND;
		}

		Sleep(1000);
	}

	return 0;
/*}

catch (int errNum) {
		perror(strerror(errNum));
		exit(1);
}*/

}
